package org.example.game.history;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/05/05 10:32
 */
public class Solution100284 {
    public static void main(String[] args) {
        System.out.println(new Solution100284().isValid("UuE6"));
    }

    public boolean isValid(String word) {

        //至少 包含 3 个字符。
        if(word == null || word.length() < 3){
            return false;
        }


        //由数字 0-9 和英文大小写字母组成。（不必包含所有这类字符。）
        if(!isValidCompose(word)){
            return false;
        }

        //至少 包含一个 元音字母 。
        String lowerWord = word.toLowerCase();
        if( !lowerWord.contains("a")
                && !lowerWord.contains("e")
                && !lowerWord.contains("i")
                && !lowerWord.contains("o")
                && !lowerWord.contains("u")
        ){
            return false;
        }

        //至少 包含一个 辅音字母 。
        lowerWord = lowerWord.replaceAll("a","");
        lowerWord = lowerWord.replaceAll("e","");
        lowerWord = lowerWord.replaceAll("i","");
        lowerWord = lowerWord.replaceAll("o","");
        lowerWord = lowerWord.replaceAll("u","");

        if(!containsLetter(lowerWord)){
            return false;
        }

        return true;
    }

    public boolean isValidCompose(String word) {
        return word.matches("[0-9a-zA-Z]+");
    }

    public static boolean containsLetter(String str) {
        return str.matches(".*[a-zA-Z]+.*");
    }


}
